﻿using System;
using System.Web.UI.WebControls;
using NazSoft.Framework.UsersManagement;
using NazSoft.Framework;

public partial class UserControls_CreateUserAccount : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnCreate_Click(object sender, EventArgs e)
    {

        UserInfo user = new UserInfo();

        user.CreatedDate = DateTime.Parse(DatetimeUtility.GetCurrentDateTime().ToShortDateString());
        TextBox txtEmailAddress = LoginView1.FindControl("txtEmailAddress") as TextBox;
        TextBox txtFirstName = LoginView1.FindControl("txtFirstName") as TextBox;
        TextBox txtLastName = LoginView1.FindControl("txtLastName") as TextBox;
        TextBox txtPassword = LoginView1.FindControl("txtPassword") as TextBox;
        TextBox txtDesignation = LoginView1.FindControl("txtDesignation") as TextBox;
        TextBox txtCellNumber = LoginView1.FindControl("txtCellNumber") as TextBox;
        TextBox txtUserName = LoginView1.FindControl("txtUserName") as TextBox;
        DropDownList ddCity = LoginView1.FindControl("ddCity") as DropDownList;
        DropDownList AreaId = LoginView1.FindControl("ddArea") as DropDownList;
        DropDownList ddBranch = LoginView1.FindControl("ddBranch") as DropDownList;


        user.Email = txtEmailAddress.Text;
        user.FirstName = txtFirstName.Text;
        user.LastName = txtLastName.Text;
        user.Password = txtPassword.Text;
        user.Designation = txtDesignation.Text;
        user.CellNumber = txtCellNumber.Text;
        user.Username = txtUserName.Text;

        //user.UserTypeId = 4;//Convert.ToInt32(ddUserType.SelectedValue);
        user.IsEnabled = true;
        user.IsApproved = false;

        int i = UserHelper.CreateUserAccount(user);

        if (i == -1)
        {
            Label lblErrorMsg = LoginView1.FindControl("lblErrorMsg") as Label;
            lblErrorMsg.Text = "Your Email Address or User Id already";
        }
        else
        {
            Session["requestSend"] = true;
            Response.Redirect("RegistrationThanks.aspx", true);
        }

    }
}
